Finding a Skip type element in a Skip

Hi all,

I am having some problems with a more complex skip structure.
What I do is, I create a Skip filled with skip type elements which in turn each have a number of skip type elements which then have int typ elements.

So the structure is

SKIP
SKIP
SKIP
INT
INT
INT
SKIP
INT
INT
INT
etc.

Each skip is put in the father skip by using a string key.

Now the problem comes when I try to retrieve a certain skip from that strucute. With the following code I can iterate over the whole structure with no problem, and it returns exactly what I need.
 

void outputMetricResult()
{
    loggerDebug("(outputMetricResult) Starting.");
        Skip skpTempOutput1, skpTempOutput2, skpTempOutput3;
        string strCmp, strMetric, strArtifactType;
        int i;
        
        // iterate over all components
        for skpTempOutput1 in skpComponents do
        {
                strCmp = (string key(skpComponents));
                loggerDebug("Component key: " strCmp "");
                // iterate over all metrics
                for skpTempOutput2 in skpTempOutput1 do
                {
                        strMetric = (string key(skpTempOutput1));
                        loggerDebug("Metric key: " strMetric "");
                        // iterate over all artifact types
                        for i in skpTempOutput2 do
                        {
                                strArtifactType = (string key(skpTempOutput2));
                                loggerDebug("Artifact Type key: " strArtifactType ": " i "");
                        }
                }
        }
        loggerDebug("(outputMetricResult) Completed.");
}

 


However when I try to find a specific skip with this code, I get an access violation. Does anyone know why?
Secondly: I have comment a part of the code out, because the third find function returns an "incorrect parameters for function find". I don't know why that happens either. I guess both are related to the fact that I try to find a skip type element in a skip.

 

 

 

string strCurrentComponent; // filled somewhere else beforehands
string strCurrentArtifactType; // filled somewhere else beforehands
Skip skpTempCmp;
Skip SkpTempMtrc;
Skip skpComponents = createString() // Structure is build somewhere else as defined above.
 
bool addValueToCurrentIntForMetric(string strMetricName, int intIncrementor)
{
    if(find(skpComponents, "" strCurrentComponent "", skpTempCmp))
        {                                                            
                if(find(skpTempCmp, "" strMetricName "", skpTempMtrc))
                {
                        /*
                        if(find(skpTempMtrc, strCurrentArtifactType, intFromSkip))
                        {
                                intFromSkip = intFromSkip + intIncrementor;
                                return true;
                        }
                        else
                        {
                                print("Couldn't find skip for artifact type: '" strCurrentArtifactType "'.");   
                                return true;
                        }
                        */
                }
                else
                {
                        print("Couldn't find skip for metric: '" strMetricName "'.");
                        return true;
                }
        }
        else
        {
                print("Couldn't find skip for component: '" strCurrentComponent "'.");
                return true;
        }
}



Grateful for any advice :-)

Best Regards,
Alexander



 

 


SystemAdmin - Tue Apr 05 05:36:19 EDT 2011

Re: Finding a Skip type element in a Skip
SystemAdmin - Tue Apr 05 05:40:19 EDT 2011

Structure should have looked like this

SKIP
....SKIP
........SKIP
............INT
............INT
............INT
........SKIP
............INT
............INT
............INT
etc.

Re: Finding a Skip type element in a Skip
Peter_Albert - Tue Apr 05 06:03:38 EDT 2011

You mixed uppercase and lowercase letters in using "SkpTempMtrc" (starting with uppercase's') in the variable definition, and "skpTempMtrc" (starting with lowercase 's') in the second call to "find".

Note, when you nest skip lists, you must be careful to loop through all lists and individually delete all child lists at the end of your script, just deleting "skpComponents" will give you a memory leak.

Regards,

Peter

Re: Finding a Skip type element in a Skip
SystemAdmin - Tue Apr 05 07:55:57 EDT 2011

Peter_Albert - Tue Apr 05 06:03:38 EDT 2011
You mixed uppercase and lowercase letters in using "SkpTempMtrc" (starting with uppercase's') in the variable definition, and "skpTempMtrc" (starting with lowercase 's') in the second call to "find".

Note, when you nest skip lists, you must be careful to loop through all lists and individually delete all child lists at the end of your script, just deleting "skpComponents" will give you a memory leak.

Regards,

Peter

Thanks Peter :-)
That's one of the things you don't see when you implement the script.

I got around the other problems in the meanwhile as well by reimplementing some DOORS functionality with my own code. Works nicely, even if rather slow ;)

Thanks for your support.

Best Regards,
Alexander

Re: Finding a Skip type element in a Skip
SystemAdmin - Tue Apr 05 08:07:05 EDT 2011

SystemAdmin - Tue Apr 05 07:55:57 EDT 2011
Thanks Peter :-)
That's one of the things you don't see when you implement the script.

I got around the other problems in the meanwhile as well by reimplementing some DOORS functionality with my own code. Works nicely, even if rather slow ;)

Thanks for your support.

Best Regards,
Alexander

This is from DXL Help is something which every DXL developer should implement - it is not default in DOORS:

Auto-declare
In DXL there is a mechanism called auto-declare, which means that a user need not specify a type for a variable. For example, in the script:

i=5
print i
the interpreter declares a new variable and deduces from the assignment that its type is int.

Because DXL is case-sensitive, there is a potential hazard when relying on this mechanism to type variables. If you make a mistake when typing a variable name, the interpreter assumes that a new variable is being used, which creates errors that are hard to find.

This feature can be disabled by adding the line:

XFLAGS_ &=~AutoDeclare_
to the bottom of the file $DOORSHOME/lib/dxl/startup.dxl.

Re: Finding a Skip type element in a Skip
Mathias Mamsch - Tue Apr 05 09:14:52 EDT 2011

SystemAdmin - Tue Apr 05 07:55:57 EDT 2011
Thanks Peter :-)
That's one of the things you don't see when you implement the script.

I got around the other problems in the meanwhile as well by reimplementing some DOORS functionality with my own code. Works nicely, even if rather slow ;)

Thanks for your support.

Best Regards,
Alexander

How big (how many elements) is the data we are talking about? The three folded skip approach will get very slow on medium to large element counts. If you are interested in speeding this up, leave a comment ;-) Regards, Mathias

Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Re: Finding a Skip type element in a Skip
llandale - Tue Apr 05 10:31:07 EDT 2011

Now I'm sure someone can find an example to prove me wrong, but I am going to say that Skip lists with 'string' KEYs MUST be created with "Skip skp =createString()". I'm guessing that your two layers of internal Skip lists have been created with "skpTempCmp = create()" instead. If so, that's the problem. Your first example extracts variables of type 'string' which work even when 'create'; your 2nd example you are searching for a literal character string (not a variable) which I think fails when used with "create".

Nit-Picks: These may matter:

I don't see any reason to search for , when strCurrentComponent will do. Its more confusing and wastes space. And if the 1st paragraph is true then this is triggering the error.

In your 2nd example, variables Skip skpTempCmp; Skip SkpTempMtrc; should be declared locally to function addValueToCurrentIntForMetric(). That info is not shared with anybody else, and declaring globally may mean that some other function may indeed rely on them after the call, which would cause a problem like an exception violation.

  • Louie

Re: Finding a Skip type element in a Skip
llandale - Tue Apr 05 10:50:55 EDT 2011

SystemAdmin - Tue Apr 05 08:07:05 EDT 2011
This is from DXL Help is something which every DXL developer should implement - it is not default in DOORS:

Auto-declare
In DXL there is a mechanism called auto-declare, which means that a user need not specify a type for a variable. For example, in the script:

i=5
print i
the interpreter declares a new variable and deduces from the assignment that its type is int.

Because DXL is case-sensitive, there is a potential hazard when relying on this mechanism to type variables. If you make a mistake when typing a variable name, the interpreter assumes that a new variable is being used, which creates errors that are hard to find.

This feature can be disabled by adding the line:

XFLAGS_ &=~AutoDeclare_
to the bottom of the file $DOORSHOME/lib/dxl/startup.dxl.

Wow, I've been barking about this for years.

There are other reasons having to do with overloaded functions:

oTarget = target(lnk).

Turns out oTarget was an "Object" in DOORS v7 and a "ModName_" in v8 triggering excessive Layout errors in my partner's sloppy code ... in every view of every module in his sloppy project ... pushing back our upgrade by two weeks and causing certain <Disallowed Content Detected> customers to show their true colors. And causing all those errors on certain Perfectly Reasonable DXL Coders client PCs, who rightfully turn off autodeclare.

But it was worth it, not having to spend one full second typing "Object ".

And its confusing.

The AutoDeclare feature provides nothing useful; except in writing code nobody else can understand preserving the author's job.

  • Louie